home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / Networking2 / SANA2 / examples / slip_device.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-11  |  4.4 KB  |  168 lines

  1. /*
  2. ** $Source: hog:Other/networking/sana2/src/slip/RCS/slip_device.h,v $
  3. ** $State: Exp $
  4. ** $Revision: 37.2 $
  5. ** $Date: 92/08/25 16:43:51 $
  6. ** $Author: kcd $
  7. **
  8. ** SANA-II Example device driver C include file
  9. **
  10. ** (C) Copyright 1992 Commodore-Amiga, Inc.
  11. */
  12.  
  13. #include <exec/types.h>
  14. #include <exec/devices.h>
  15. #include <exec/ports.h>
  16. #include <exec/semaphores.h>
  17. #include <exec/memory.h>
  18. #include <dos.h>
  19. #include <devices/sana2.h>
  20. #include <devices/serial.h>
  21.  
  22. /*
  23. ** Stacksize and Priority of the Unit Process
  24. */
  25. #define SLIP_STACKSIZE 4000
  26. #define SLIP_PRI 5
  27.  
  28. /*
  29. ** Maximum Transmission Unit
  30. */
  31. #define SLIP_MTU 1006
  32.  
  33. /*
  34. ** Max # of Units allowed
  35. */
  36. #define SD_MAXUNITS 8
  37.  
  38. /*
  39. ** Message passed to the Unit Process at
  40. ** startup time.
  41. */
  42. struct StartupMessage
  43. {
  44.     struct Message    Msg;
  45.     struct Unit    *Unit;
  46.     struct Device    *Device;
  47. };
  48.  
  49. /*
  50. ** Device Data Structure
  51. */
  52. struct SLIPDevice
  53. {
  54.     struct Library     sd_Device;
  55.     UBYTE         sd_Flags;
  56.     UBYTE         sd_Pad1;
  57.     struct Library    *sd_SysBase;
  58.     struct Library    *sd_DOSBase;
  59.     ULONG         sd_DosTag[10];
  60.     BPTR         sd_SegList;
  61.     struct Unit        *sd_Units[SD_MAXUNITS];
  62.     struct SignalSemaphore sd_Lock;
  63.     struct StartupMessage sd_Startup;
  64. };
  65.  
  66. /*
  67. ** Typedef's for the SANA-II callback functions.
  68. */
  69. typedef BOOL (*SANA2_CFB)(APTR to, APTR from, LONG length);
  70. typedef BOOL (*SANA2_CTB)(APTR to, APTR from, LONG length);
  71.  
  72. struct BufferManagement
  73. {
  74.     struct MinNode    bm_Node;
  75.     SANA2_CFB        bm_CopyFromBuffer;
  76.     SANA2_CTB        bm_CopyToBuffer;
  77. };
  78.  
  79. struct SuperS2PTStats
  80. {
  81.     struct MinNode        ss_Node;
  82.     ULONG            ss_PType;
  83.     struct Sana2PacketTypeStats    ss_Stats;
  84. };
  85.  
  86. /*
  87. ** Unit Data Structure
  88. */
  89. struct SLIPDevUnit
  90. {
  91.     struct Unit             sdu_Unit;        /* Standard Unit Structure */
  92.     UBYTE             sdu_UnitNum;        /* Unit number */
  93.     UBYTE             sdu_Reserved0;        /* Padding */
  94.     struct Device        *sdu_Device;        /* Pointer to our device node */
  95.     ULONG             sdu_StAddr;        /* Our "hardware" address */
  96.     ULONG             sdu_BaudRate;        /* Serial baud rate */
  97.     ULONG             sdu_SerUnitNum;    /* Serial driver unit number */
  98.     BOOL             sdu_NoMore;        /* ??? */
  99.     BOOL             sdu_Escape;        /* SLIP Decode state */
  100.     ULONG             sdu_State;        /* Various state information */
  101.     struct IOExtSer         *sdu_SerRx;        /* Serial IORequest for CMD_READ's */
  102.     struct IOExtSer         *sdu_SerTx;        /* Serial IORequest for CMD_WRITE's */
  103.     struct MsgPort         *sdu_RxPort;        /* Serial CMD_READ IORequest reply port */
  104.     struct MsgPort         *sdu_TxPort;        /* Serial CMD_WRITE IORequest reply port */
  105.     UBYTE            *sdu_RxBuff;        /* Buffer for holding decoded packets */
  106.     UBYTE            *sdu_RxBuffPtr;        /* Current place in decode buffer */
  107.     UBYTE            *sdu_TxBuff;        /* Temporary buffer for hold unencoded outgoing packets */
  108.     UBYTE            *sdu_RxSLIP;        /* Two buffers that hold packets encoded */
  109.     UBYTE            *sdu_TxSLIP;        /* in SLIP format. */
  110.     struct Process        *sdu_Proc;         /* NB: This points to the Task, not the MsgPort */
  111.     struct SignalSemaphore     sdu_ListLock;        /* A Semaphore for access to all of our queues. */
  112.     struct MinList         sdu_Rx;                /* Pending CMD_READ's */
  113.     struct MinList         sdu_RxOrph;        /* Pending CMD_READORPHAN's */
  114.     struct MinList          sdu_Tx;        /* Pending CMD_WRITE's */
  115.     struct MinList          sdu_Events;        /* Pending S2_ONEVENT's */
  116.     struct SuperS2PTStats    *sdu_IPTrack;        /* For tracking IP packets */
  117.     struct MinList          sdu_Track;        /* List of packet types being tracked */
  118.     struct MinList         sdu_BuffMgmt;        /* List of Callback routines */
  119.     struct Sana2DeviceStats     sdu_Stats;        /* Global device statistics */
  120.     UBYTE              sdu_SerDevName[32];    /* Name of the serial driver to use */
  121. };
  122.  
  123. /*
  124. ** State bits for sdu_State
  125. */
  126.  
  127. #define SLIPUB_CONFIG 0
  128. #define SLIPUB_ONLINE 1
  129. #define SLIPUB_SETCONFIG 2
  130. #define SLIPUB_CD 3
  131. #define SLIPUB_EXCLUSIVE 4
  132. #define SLIPUB_7WIRE 5
  133.  
  134. #define SLIPUF_CONFIG        (1<<SLIPUB_CONFIG)
  135. #define SLIPUF_ONLINE        (1<<SLIPUB_ONLINE)
  136. #define SLIPUF_SETCONFIG    (1<<SLIPUB_SETCONFIG)
  137. #define SLIPUF_CD        (1<<SLIPUB_CD)
  138. #define SLIPUF_EXCLUSIVE    (1<<SLIPUB_EXCLUSIVE)
  139. #define SLIPUF_7WIRE        (1<<SLIPUB_7WIRE)
  140.  
  141. /*
  142. ** Device Name
  143. */
  144.  
  145. #define SLIPDEVNAME "slip.device"
  146.  
  147. /*
  148. ** Packet Encoding Bytes
  149. */
  150.  
  151. #define SLIP_END     192
  152. #define SLIP_ESC     219
  153. #define SLIP_ESC_END 220
  154. #define SLIP_ESC_ESC 221
  155.  
  156. /*
  157. ** Compiler Magic
  158. **
  159. */
  160. #define SLIPBase ((struct SLIPDevice *)__builtin_getreg(14))    /* Avoid the pre-processor problem */
  161.  
  162. #define SysBase        (SLIPBase->sd_SysBase)
  163. #define DOSBase        (SLIPBase->sd_DOSBase)
  164.  
  165. #define ASM           __asm
  166. #define REG(x)        register __ ## x
  167.  
  168.